import { Component, Vue } from 'vue-property-decorator'
import Avatar from '@avatar';
import { User } from '@entity/user';
import ws from '@ws';

@Component({
    components: {
        Avatar
    }
})
export class UserAndLoginComponent extends Vue {

    /**
     * 登出, 注销
     */
    private logout(): void {
        this.$store.commit('logout'); 
        this.$router.replace('/login')
    }

    /**
     * 建立 websocket 连接并获取用户
     */
    private get user(): User {
        ws.init();
        return this.$store.getters.me();
    }

    private get noLogin(): boolean {
        return this.$store.getters.me() === undefined;
    }

}